package work.mediway.mdm.controller.patient;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.mediway.hos.base.model.BaseResponse;
import com.mediway.hos.log.annotation.OperLog;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import work.mediway.mdm.core.page.QueryRequest;
import work.mediway.mdm.biz.bo.DictPushBO;
import work.mediway.mdm.core.annotation.OpsLog;
import work.mediway.mdm.core.constant.JobConstant;
import work.mediway.mdm.core.enums.CodeAndMessageEnum;
import work.mediway.mdm.core.enums.MdmModelEnum;
import work.mediway.mdm.core.enums.OpsLogTypeEnum;
import work.mediway.mdm.core.exception.DataException;
import work.mediway.mdm.core.transport.ErrorMsgVO;
import work.mediway.mdm.biz.dto.patient.PatientDTO;
import work.mediway.mdm.biz.dto.patient.PatientMergeDTO;
import work.mediway.mdm.biz.dto.patient.PatientQueryDTO;
import work.mediway.mdm.biz.dto.patient.PatientStorageDTO;
import work.mediway.mdm.biz.dto.patient.PatientSuspectDTO;
import work.mediway.mdm.biz.entity.biz.UserBTEventLog;
import work.mediway.mdm.biz.entity.patient.PatientConfig;
import work.mediway.mdm.biz.service.biz.UserBTEventLogService;
import work.mediway.mdm.biz.service.common.CommonDictService;
import work.mediway.mdm.biz.service.patient.PaAddressService;
import work.mediway.mdm.biz.service.patient.PaMergePatientLogService;
import work.mediway.mdm.biz.service.patient.PaPatientService;
import work.mediway.mdm.biz.service.patient.PaSuspectPatientService;
import work.mediway.mdm.biz.service.patient.PatientConfigService;
import work.mediway.mdm.biz.service.patient.RelPatientService;
import work.mediway.mdm.biz.vo.patient.PatientDetailVO;
import work.mediway.mdm.biz.vo.patient.PatientListVO;
import work.mediway.mdm.biz.vo.patient.PatientMergeListVO;
import work.mediway.mdm.biz.vo.patient.PatientMergeLogListVO;
import work.mediway.mdm.biz.vo.patient.RelPatientVO;
import work.mediway.mdm.biz.vo.patient.StatisticsPatientNumVO;
import work.mediway.mdm.biz.vo.patient.SuspectPatientDetailVO;
import work.mediway.mdm.biz.vo.patient.SuspectPatientListVO;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2020/11/27
 */
@Api(tags = "患者数据模块")
@ApiSupport(order = 9)
@Validated
@RequestMapping("patient")
@RestController
@RequiredArgsConstructor
public class PatientController {

    private final PaPatientService paPatientService;
    private final PaAddressService paAddressService;
    private final UserBTEventLogService userBtEventLogService;
    private final PatientConfigService patientConfigService;
    private final PaSuspectPatientService suspectPatientService;
    private final PaMergePatientLogService mergePatientLogService;
    private final RelPatientService relPatientService;

    /*======================================================== 患者统计 =================================================*/

    @OpsLog(value = "统计患者地区分布", type = OpsLogTypeEnum.ANALYSIS)
    @GetMapping("statistics/area")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "统计患者地区分布")
    @ApiImplicitParam(value = "住址类型", name = "addressTypeCode", paramType = "query")
    public BaseResponse<Object> statisticsNumByArea(String addressTypeCode) {
        LambdaQueryWrapper<UserBTEventLog> queryWrapper = Wrappers.lambdaQuery(UserBTEventLog.class);
        queryWrapper.eq(UserBTEventLog::getBtCode, JobConstant.CONST_PATIENT_AREA_STATISTICS_KEY)
                .eq(UserBTEventLog::getLastUpdateDate, DateUtil.today());
        List<UserBTEventLog> eventLogs = this.userBtEventLogService.list(queryWrapper);
        if (CollUtil.isEmpty(eventLogs)) {
            Map<String, List<Map<String, Object>>> numByArea = this.paAddressService.statisticsNumByArea(addressTypeCode);
            UserBTEventLog userBtEventLog = new UserBTEventLog(JobConstant.CONST_PATIENT_AREA_STATISTICS_KEY
                    , JSONUtil.toJsonStr(numByArea), DateUtil.today());
            this.userBtEventLogService.saveBtEventLog(userBtEventLog);
            return CollUtil.isNotEmpty(numByArea) ? BaseResponse.success(numByArea) : BaseResponse.error(String.valueOf(CodeAndMessageEnum.DB_RESOURCE_NULL.getCode()), CodeAndMessageEnum.DB_RESOURCE_NULL.getMessage());
        }

        // 格式化key ,value
        String btDetails = eventLogs.get(0).getBtDetails();
        JSONObject statisRes = new JSONObject();
        if (JSONUtil.isJsonObj(btDetails)) {
            JSONObject area = JSONUtil.parseObj(btDetails);
            area.forEach((k, v) -> {
                JSONArray arrayTmp = new JSONArray();
                for (Object detail : JSONUtil.parseArray(v)) {
                    JSONObject detailObj = JSONUtil.parseObj(detail);
                    JSONObject objectTmp = new JSONObject();
                    detailObj.forEach((key, val) -> {
                        if (StrUtil.equals(key, "patientNum")) {
                            objectTmp.set("value", val);
                        } else {
                            objectTmp.set("name", val);
                        }
                    });
                    arrayTmp.add(objectTmp);
                }
                statisRes.set(k, arrayTmp);
            });
        }
        return CollUtil.isNotEmpty(eventLogs) ? BaseResponse.success(statisRes) : BaseResponse.error(String.valueOf(CodeAndMessageEnum.DB_RESOURCE_NULL.getCode()), CodeAndMessageEnum.DB_RESOURCE_NULL.getMessage());
    }

    @OpsLog(value = "统计患者日增长量", type = OpsLogTypeEnum.ANALYSIS)
    @GetMapping("statistics/increase")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "统计患者日增长量", notes = "可自定义区间范围")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "起始日期,格式为yyyy-MM-dd", name = "startDate", paramType = "query", required = true),
            @ApiImplicitParam(value = "截止日期,格式为yyyy-MM-dd", name = "endDate", paramType = "query", required = true)
    })
    public BaseResponse<List<Map<String, String>>> statisticsNumGroupByDay(@NotBlank(message = "统计的起始日期,格式为yyyy-MM-dd") @Pattern(regexp = "^[0-9]{4}-[0-9]{2}-[0-9]{2}$", message = "日期格式不正确,正确为yyyy-MM-dd") String startDate
            , @NotBlank(message = "统计的截止日期,格式为yyyy-MM-dd") @Pattern(regexp = "^[0-9]{4}-[0-9]{2}-[0-9]{2}$", message = "日期格式不正确,正确为yyyy-MM-dd") String endDate) {
        List<Map<String, String>> result = this.paPatientService.statisticsNumGroupByDay(startDate, endDate);
        return ObjectUtil.isNotEmpty(result) ? BaseResponse.success(result) : BaseResponse.error(String.valueOf(CodeAndMessageEnum.DB_RESOURCE_NULL.getCode()), CodeAndMessageEnum.DB_RESOURCE_NULL.getMessage());
    }

    @OpsLog(value = "统计患者年龄分布", type = OpsLogTypeEnum.ANALYSIS)
    @GetMapping("statistics/age")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "统计患者年龄分布")
    public BaseResponse<JSON> statisticsNumAge() {
        LambdaQueryWrapper<UserBTEventLog> queryWrapper = Wrappers.lambdaQuery(UserBTEventLog.class);
        queryWrapper.eq(UserBTEventLog::getBtCode, JobConstant.CONST_PATIENT_AGE_STATISTICS_KEY)
                .eq(UserBTEventLog::getLastUpdateDate, DateUtil.today());
        List<UserBTEventLog> eventLogs = this.userBtEventLogService.list(queryWrapper);
        if (CollUtil.isEmpty(eventLogs)) {
            Map<String, Object> numAge = this.paPatientService.statisticsNumAge();
            UserBTEventLog userBtEventLog = new UserBTEventLog(JobConstant.CONST_PATIENT_AGE_STATISTICS_KEY
                    , JSONUtil.toJsonStr(numAge), DateUtil.today());
            this.userBtEventLogService.saveBtEventLog(userBtEventLog);
            return CollUtil.isNotEmpty(numAge) ? BaseResponse.success(JSONUtil.parse(numAge)) : BaseResponse.error(String.valueOf(CodeAndMessageEnum.DB_RESOURCE_NULL.getCode()), CodeAndMessageEnum.DB_RESOURCE_NULL.getMessage());
        }
        return CollUtil.isNotEmpty(eventLogs) ? BaseResponse.success(JSONUtil.parse(eventLogs.get(0).getBtDetails())) : BaseResponse.error(String.valueOf(CodeAndMessageEnum.DB_RESOURCE_NULL.getCode()), CodeAndMessageEnum.DB_RESOURCE_NULL.getMessage());
    }

    @OpsLog(value = "统计患者整体信息", type = OpsLogTypeEnum.ANALYSIS)
    @GetMapping("statistics")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "统计患者整体信息")
    public BaseResponse<JSON> statisticsPatient() {
        LambdaQueryWrapper<UserBTEventLog> queryWrapper = Wrappers.lambdaQuery(UserBTEventLog.class);
        queryWrapper.eq(UserBTEventLog::getBtCode, JobConstant.CONST_PATIENT_KEY)
                .eq(UserBTEventLog::getLastUpdateDate, DateUtil.today());
        List<UserBTEventLog> eventLogs = this.userBtEventLogService.list(queryWrapper);
        if (CollUtil.isEmpty(eventLogs)) {
            StatisticsPatientNumVO patient = this.paPatientService.statisticsPatient();
            UserBTEventLog userBtEventLog = this.userBtEventLogService.buildPatientEventLog(patient);
            this.userBtEventLogService.saveBtEventLog(userBtEventLog);
            return ObjectUtil.isNotEmpty(patient) ? BaseResponse.success(JSONUtil.parse(patient)) : BaseResponse.error(String.valueOf(CodeAndMessageEnum.DB_RESOURCE_NULL.getCode()), CodeAndMessageEnum.DB_RESOURCE_NULL.getMessage());
        }
        return CollUtil.isNotEmpty(eventLogs) ? BaseResponse.success(JSONUtil.parse(eventLogs.get(0).getBtDetails())) : BaseResponse.error(String.valueOf(CodeAndMessageEnum.DB_RESOURCE_NULL.getCode()), CodeAndMessageEnum.DB_RESOURCE_NULL.getMessage());
    }

    /*======================================================== 患者基础信息 =================================================*/

    @OpsLog(value = "查询患者列表信息", type = OpsLogTypeEnum.SELECT)
    @GetMapping("list")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "查询患者列表信息")
    public BaseResponse<Page<PatientListVO>> pagePatientList(QueryRequest queryRequest, PatientDTO patient) {
        Page<PatientListVO> result = this.paPatientService.pagePatientList(queryRequest, patient);
        return ObjectUtil.isNotEmpty(result) ? BaseResponse.success(result) : BaseResponse.error(String.valueOf(CodeAndMessageEnum.DB_RESOURCE_NULL.getCode()), CodeAndMessageEnum.DB_RESOURCE_NULL.getMessage());
    }

    @OpsLog(value = "根据患者Id查询基础信息", type = OpsLogTypeEnum.SELECT)
    @GetMapping("detail")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "根据患者Id查询基础信息", notes = "患者平台Id和患者院内Id不能同时为空")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "患者平台Id", name = "patPatientId", paramType = "query"),
            @ApiImplicitParam(value = "患者院内Id", name = "hosPatientId", paramType = "query")
    })
    public BaseResponse<PatientDetailVO> getPatientDetail(String patPatientId, String hosPatientId) {
        PatientDetailVO result = this.paPatientService.getPatientDetail(patPatientId, hosPatientId);
        return ObjectUtil.isNotEmpty(result) ? BaseResponse.success(result) : BaseResponse.error(String.valueOf(CodeAndMessageEnum.DB_RESOURCE_NULL.getCode()), CodeAndMessageEnum.DB_RESOURCE_NULL.getMessage());
    }

    /*======================================================== 患者权重 =================================================*/

    @OpsLog(value = "查询患者权重列表", type = OpsLogTypeEnum.SELECT)
    @GetMapping("weight/list")
    @ApiOperationSupport(order = 7)
    @ApiOperation("查询患者权重列表")
    public BaseResponse<Page<PatientConfig>> pagePatientWeight(PatientConfig patientConfig, QueryRequest queryRequest) {
        Page<PatientConfig> result = this.patientConfigService.pagePatientWeight(patientConfig, queryRequest);
        return ObjectUtil.isNotEmpty(result) ? BaseResponse.success(result) : BaseResponse.error(String.valueOf(CodeAndMessageEnum.DB_RESOURCE_NULL.getCode()), CodeAndMessageEnum.DB_RESOURCE_NULL.getMessage());
    }

    @OperLog(title = "新增患者权重信息", content = "新增患者权重信息")
    @OpsLog(value = "新增患者权重信息", type = OpsLogTypeEnum.INSERT)
    @PostMapping("weight")
    @ApiOperationSupport(order = 8)
    @ApiOperation("新增患者权重信息")
    public BaseResponse<String> addPatientWeight(@Valid PatientConfig patientConfig) {
        if (ObjectUtil.isNotEmpty(this.patientConfigService.getOne(new LambdaQueryWrapper<>(new PatientConfig()).eq(PatientConfig::getIndexCode, patientConfig.getIndexCode())))) {
            throw new DataException(StrUtil.format("indexCode = {} 已存在, 请重新输入", patientConfig.getIndexCode()));
        }
        this.patientConfigService.save(patientConfig);
        return BaseResponse.success();
    }

    @OperLog(title = "更新患者权重信息", content = "更新患者权重信息")
    @OpsLog(value = "更新患者权重信息", type = OpsLogTypeEnum.UPDATE)
    @PostMapping("weight/update")
    @ApiOperationSupport(order = 9)
    @ApiOperation(value = "更新患者权重信息", notes = "需要将之前数据一起传入,否则会丢失之前的数据")
    public BaseResponse<String> updatePatientWeight(@Valid PatientConfig patientConfig) {
        String msg = CodeAndMessageEnum.SUCCESS.getMessage();
        LambdaQueryWrapper<PatientConfig> wrapper = Wrappers.lambdaQuery(PatientConfig.class);
        if (StrUtil.isNotBlank(patientConfig.getIndexCode())) {
            wrapper.eq(PatientConfig::getIndexCode, patientConfig.getIndexCode());
        }
        PatientConfig one = this.patientConfigService.getOne(wrapper);
        if (ObjectUtil.isEmpty(one)) {
            throw new DataException("权重信息项代码【indexCode = " + patientConfig.getIndexCode() + "】不存在");
        }
        patientConfig.setIndexCode(one.getIndexCode());
        this.patientConfigService.updateById(patientConfig);
        return BaseResponse.success(msg);
    }

    @OperLog(title = "删除患者权重信息", content = "删除患者权重信息")
    @OpsLog(value = "删除患者权重信息", type = OpsLogTypeEnum.DELETE)
    @PostMapping("weight/delete")
    @ApiOperationSupport(order = 10)
    @ApiOperation(value = "删除患者权重信息", notes = "多个代码之间使用|分隔")
    @ApiImplicitParam(value = "权重信息项代码(多个之间使用|分隔)", name = "indexCodes", paramType = "query", required = true)
    public BaseResponse<String> deletePatientWeight(@NotBlank(message = "权重信息项代码不能为空") String indexCodes) {
        this.patientConfigService.removeByIds(StrUtil.splitTrim(indexCodes, StringPool.PIPE));
        return BaseResponse.success();
    }

    /*======================================================== 相似患者 =================================================*/

    @OpsLog(value = "查询相似患者列表", type = OpsLogTypeEnum.SELECT)
    @GetMapping("suspect")
    @ApiOperationSupport(order = 11)
    @ApiOperation(value = "查询相似患者列表")
    public BaseResponse<Page<SuspectPatientListVO>> pageSuspectPatient(PatientSuspectDTO suspectDTO, QueryRequest queryRequest) {
        Page<SuspectPatientListVO> result = this.suspectPatientService.pageSuspectPatient(suspectDTO, queryRequest);
        return ObjectUtil.isNotEmpty(result) ? BaseResponse.success(result) : BaseResponse.error(String.valueOf(CodeAndMessageEnum.DB_RESOURCE_NULL.getCode()), CodeAndMessageEnum.DB_RESOURCE_NULL.getMessage());
    }

    @OpsLog(value = "查询相似关联患者", type = OpsLogTypeEnum.SELECT)
    @GetMapping("suspect/detail")
    @ApiOperationSupport(order = 12)
    @ApiOperation(value = "查询相似关联患者")
    @ApiImplicitParam(value = "患者平台Id", name = "patPatientId", paramType = "query", required = true)
    public BaseResponse<List<SuspectPatientDetailVO>> suspectPatientDetail(@NotBlank(message = "患者平台Id不能为空") String patPatientId) {
        List<SuspectPatientDetailVO> result = this.suspectPatientService.suspectPatientDetail(patPatientId);
        return CollUtil.isNotEmpty(result) ? BaseResponse.success(result) : BaseResponse.error(String.valueOf(CodeAndMessageEnum.DB_RESOURCE_NULL.getCode()), CodeAndMessageEnum.DB_RESOURCE_NULL.getMessage());
    }

    /*======================================================== 合并患者 =================================================*/

    @OpsLog(value = "查询患者合并列表", type = OpsLogTypeEnum.SELECT)
    @GetMapping("merge")
    @ApiOperationSupport(order = 13)
    @ApiOperation(value = "查询患者合并列表")
    public BaseResponse<List<PatientMergeListVO>> pageMergePatient(PatientMergeDTO mergeDTO, QueryRequest queryRequest) {
        List<PatientMergeListVO> result = this.mergePatientLogService.pageMergePatient(mergeDTO, queryRequest);
        return CollUtil.isNotEmpty(result) ? BaseResponse.success(result) : BaseResponse.error(String.valueOf(CodeAndMessageEnum.DB_RESOURCE_NULL.getCode()), CodeAndMessageEnum.DB_RESOURCE_NULL.getMessage());
    }

    @OperLog(title = "合并相似患者", content = "合并相似患者")
    @OpsLog(value = "合并相似患者", type = OpsLogTypeEnum.UPDATE)
    @PostMapping("merge")
    @ApiOperationSupport(order = 14)
    @ApiOperation(value = "合并相似患者")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "主患者平台Id", name = "majorPatPatientId", paramType = "query", required = true),
            @ApiImplicitParam(value = "次患者平台Id(多个之间使用|分隔)", name = "minorPatPatientIds", paramType = "query", required = true),
    })
    public BaseResponse<String> mergePatient(@NotBlank(message = "主患者平台Id不能为空") String majorPatPatientId
            , @NotBlank(message = "次患者平台Id不能为空") String minorPatPatientIds) {
        this.mergePatientLogService.mergePatient(majorPatPatientId, minorPatPatientIds);
        return BaseResponse.success();
    }

    @OpsLog(value = "查询患者合并日志列表", type = OpsLogTypeEnum.SELECT)
    @GetMapping("merge/log")
    @ApiOperationSupport(order = 15)
    @ApiOperation(value = "查询患者合并日志列表")
    public BaseResponse<Page<PatientMergeLogListVO>> pageMergePatientLog(PatientMergeDTO mergeDTO, QueryRequest queryRequest) {
        Page<PatientMergeLogListVO> result = this.mergePatientLogService.pageMergePatientLog(mergeDTO, queryRequest);
        return ObjectUtil.isNotEmpty(result) ? BaseResponse.success(result) : BaseResponse.error(String.valueOf(CodeAndMessageEnum.DB_RESOURCE_NULL.getCode()), CodeAndMessageEnum.DB_RESOURCE_NULL.getMessage());
    }

    @OperLog(title = "取消相似患者合并", content = "取消相似患者合并")
    @OpsLog(value = "取消相似患者合并", type = OpsLogTypeEnum.UPDATE)
    @PostMapping("merge/cancel")
    @ApiOperationSupport(order = 16)
    @ApiOperation(value = "取消相似患者合并")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "合并前患者平台Id", name = "mergePatOldPatientId", paramType = "query", required = true),
            @ApiImplicitParam(value = "合并后患者平台Id", name = "mergePatPatientId", paramType = "query", required = true)
    })
    public BaseResponse<String> mergeCancelPatient(@NotBlank(message = "合并前患者平台Id不能为空") String mergePatOldPatientId
            , @NotBlank(message = "合并后患者平台Id不能为空") String mergePatPatientId) {
        this.mergePatientLogService.mergeCancelPatient(mergePatOldPatientId, mergePatPatientId);
        return BaseResponse.success();
    }

    @OpsLog(value = "查询患者渠道信息", type = OpsLogTypeEnum.DELETE)
    @PostMapping("path")
    @ApiOperationSupport(order = 18)
    @ApiOperation(value = "查询患者渠道信息")
    public BaseResponse<List<String>> patientPath() {
        List<String> result = this.paPatientService.patientPath();
        return BaseResponse.success(result);
    }

    @OperLog(title = "患者信息",content = "存储患者信息")
    @OpsLog(value = "存储患者信息", type = OpsLogTypeEnum.INSERT)
    @PostMapping("/add")
    @ApiOperationSupport(order = 20)
    @ApiOperation(value = "存储患者信息")
    public BaseResponse<ErrorMsgVO> patientSave(@RequestBody PatientStorageDTO patientStorageDTO) {
        ErrorMsgVO errorMsgVO = this.relPatientService.patientSave(patientStorageDTO);
        return BaseResponse.success(errorMsgVO);
    }

    @OperLog(title = "患者信息",content = "查询患者详细信息")
    @OpsLog(value = "查询患者详细信息", type = OpsLogTypeEnum.SELECT)
    @PostMapping("/query")
    @ApiOperationSupport(order = 22)
    @ApiOperation(value = "查询患者详细信息")
    public BaseResponse<Page<RelPatientVO>> patientList(@RequestBody PatientQueryDTO patientQueryDTO) {
        Page<RelPatientVO> page = this.relPatientService.patientList(patientQueryDTO);
        return BaseResponse.success(page);
    }

    @OperLog(title = "患者信息",content = "推送患者信息")
    @OpsLog(value = "推送患者信息", type = OpsLogTypeEnum.SELECT)
    @PostMapping("/push")
    @ApiOperationSupport(order = 24)
    @ApiOperation(value = "推送患者信息")
    public BaseResponse<String> patientPush(@RequestBody PatientQueryDTO patientQueryDTO) {
        Page<RelPatientVO> page = this.relPatientService.patientList(patientQueryDTO);
        DictPushBO dictPushBO = new DictPushBO(MdmModelEnum.PA_Patient.name(), JSONUtil.toJsonPrettyStr(page.getRecords()));
        SpringUtil.getBean(CommonDictService.class).pushDict(dictPushBO);
        return BaseResponse.success();
    }
}